home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Diamond Collection / The Diamond Collection (Software Vault)(Digital Impact).ISO / cdr13 / aurora2c.zip / CLRCHART.AML < prev    next >
Text File  |  1995-04-07  |  4KB  |  129 lines

  1.  
  2. // ───────────────────────────────────────────────────────────────────
  3. // Simple color chart  2/2/94
  4. //
  5. // This external AML macro displays a color chart with color attribute
  6. // codes in decimal and hexidecimal. It can be helpful when configuring
  7. // COLOR.AML. To enter a color string (e.g. 'red on blue') in your text:
  8. //
  9. //   1. run this macro
  10. //   2. position the cursor to the desired color
  11. //   3. press <enter>
  12. //
  13. // An easy way to run this macro is to place it in your MACRO
  14. // subdirectory and select it from the macro picklist <shift f12>.
  15. // Don't forget to compile it first. To compile, press <shift f10>
  16. // when this source is displayed in an edit window.
  17. // ───────────────────────────────────────────────────────────────────
  18.  
  19.   include bootpath "define.aml"
  20.  
  21.   var foreground
  22.   var background
  23.  
  24.   // return the color name for a color attribute
  25.   function attrname (attr)
  26.     case attr
  27.       when  0 "black"       when  8 "darkgray"
  28.       when  1 "blue"        when  9 "brightblue"
  29.       when  2 "green"       when 10 "brightgreen"
  30.       when  3 "cyan"        when 11 "brightcyan"
  31.       when  4 "red"         when 12 "brightred"
  32.       when  5 "magenta"     when 13 "brightmagenta"
  33.       when  6 "brown"       when 14 "yellow"
  34.       when  7 "gray"        when 15 "white"
  35.     end
  36.   end
  37.  
  38.   // create the color chart window
  39.   createwindow
  40.   setwinobj
  41.   setframe ">b"
  42.   setcolor  border_color   color gray  on black
  43.   setcolor  text_color     color black on black
  44.   settitle "Color Chart - press <enter> to select"
  45.   setwinctrl '≡'
  46.   sizewindow 27 4 74 20 "ad"
  47.   setborder "1f"
  48.  
  49.   // draw the color chart
  50.   while foreground < 16 do
  51.     while background < 16 do
  52.       writestr " A "  background * 16 + foreground
  53.       background = background + 1
  54.     end
  55.     writeline
  56.     background = 0
  57.     foreground = foreground + 1
  58.   end
  59.  
  60.   foreground = 0
  61.   background = 0
  62.   showcursor 50 99
  63.  
  64.   loop
  65.     attr = foreground + background * 16
  66.     colorstring = (attrname foreground) + ' on ' + (attrname background)
  67.  
  68.     // write color info at the bottom of the chart
  69.     writestr '[dec=' + attr + ',hex=' + (base attr 16) + '] ' +
  70.               colorstring + "                "
  71.              (color gray on black) 2 17
  72.  
  73.     // move the cursor to the appropriate color cell
  74.     x = background * 3 + 2
  75.     gotoxy x foreground + 1
  76.  
  77.     // write the bracket [ ] cursor
  78.     attr = (if? background > brightblue black white) + background * 16
  79.     writestr '[' attr  x - 1
  80.     writestr ']' attr  x + 1
  81.     gotoxy x foreground + 1
  82.  
  83.     // display the window and get the next key
  84.     keycode = getkey
  85.  
  86.     // clear the bracket cursor
  87.     writestr " A "  foreground + background * 16   x - 1
  88.  
  89.     case keycode
  90.  
  91.       // exit the chart
  92.       when <esc>
  93.         break
  94.  
  95.       // mouse click
  96.       when <button>
  97.         case getregion
  98.           // client area
  99.           when 1
  100.             if virtorow <= 16 then
  101.               foreground = (virtorow - 1) mod 16
  102.             end
  103.             background = (virtocol - 1) / 3
  104.           // close icon
  105.           when 51
  106.             break
  107.         end
  108.  
  109.       // enter the color description in an edit window and exit
  110.       when <enter>
  111.         queue "write" colorstring
  112.         break
  113.  
  114.       // move the cursor around in the chart
  115.       when <left>
  116.         background = if? background (background - 1) 15
  117.       when <right>
  118.         background = (background + 1) mod 16
  119.       when <up>
  120.         foreground = if? foreground (foreground - 1) 15
  121.       when <down>
  122.         foreground = (foreground + 1) mod 16
  123.     end
  124.   end
  125.  
  126.   // destroy the color chart window
  127.   destroywindow
  128.  
  129.